//
//  ThemeSwitcherView.swift
//  NaiCha
//
//  Created by 唐安坤 on 2024/9/24.
//

import SwiftUI

struct ThemeSwitcherView: View {
    
    @State var pickerSelection = "light"
    var body: some View {
       
        VStack{
            Circle().foregroundColor(Color("bgColor", bundle: nil)).overlay {
                VStack{
                    Rectangle()
                        .frame(width: 100,height: 100)
                        .foregroundColor( Color(.systemBackground))
                }
            }.background(.red)
            
            Picker(selection: $pickerSelection) {
                Text("系统").tag("system")
                Text("深色").tag("dark")
                Text("浅色").tag("light")
            } label: {
                
            }.pickerStyle(.inline)
             .preferredColorScheme(getSchemeColor(pickerSelection: pickerSelection))
        }
    }
}

func getSchemeColor(pickerSelection: String)->ColorScheme?{
    switch pickerSelection {
    case "dark":
        return .dark
    case "light":
        return .light
    default:
        return nil
    }
    
}



#Preview {
    ThemeSwitcherView()
}
